﻿using System;
using System.Xml;
using System.Collections.Generic;
using System.ServiceModel;
using Corona.TagContract;

namespace Corona.TagContract
{
    [ServiceContract]
    public interface ITagServer
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="UID">Xml描述文件的UID</param>
        /// <param name="types">类型</param>
        /// <returns>指定UID的资源的完整描述</returns>
        [OperationContract]
        string GetXmlByUID(long UID,string[] tagNames);
        /// <summary>
        /// 执行查询请求，通过lucene提供的查询接口进行查询
        /// </summary>
        /// <param name="queryString">以字符串的形式传入查询请求</param>
        /// <param name="revalance">相关度，在[0,1]之间</param>
        /// <returns>查询结果中资源对应的UID</returns>
        [OperationContract]
        long[] Search(string queryString);

        /// <summary>
        /// 获得强连接函数
        /// 仅当客户端越过AppSupport直接使用ServerSupport时需要关注
        /// </summary>
        /// <param name="queryString">必须是一个相关度为1的Query的ToString方法得来</param>
        /// <param name="appVerify">应用程序验证字符串，由AppName:md5ofxml构成，如:"Corona:7f5484da48dab5bcda"</param>
        /// <returns>得到富描述对应的uid，如没有会新建一个返回；验证失败则返回0</returns>
        [OperationContract]
        long GetStrongLink(string queryString,string appVerify);

        /// <summary>
        /// 给一个富描述增加标签的函数
        /// </summary>
        /// <param name="UID">资源/富描述的uid</param>
        /// <param name="Tags">标签</param>
        /// <param name="appVerify">验证字符串</param>
        /// <returns>成功为1，权限不足为0，服务器异常为-1</returns>
        [OperationContract]
        int Update(long UID, IEnumerable<Tag> Tags,string appVerify);

        /// <summary>
        /// 获得相关标签
        /// </summary>
        /// <param name="tagjar">有数值关系的标签组，反映权重</param>
        /// <param name="relevance">相关度</param>
        /// <returns>相关强度</returns>
        [OperationContract]
        TagJar GetTagJar(TagJar tagjar, double relevance);

        /// <summary>
        /// 注册应用
        /// </summary>
        /// <param name="registerXML">须符合CoronaAppRegister.xsd</param>
        /// <returns>通过审核修改后的XML；返回空表示尚未通过审核</returns>
        [OperationContract]
        string RegisterApp(string registerXML);

        /// <summary>
        /// 删除本应用添加的Tag
        /// </summary>
        /// <param name="uid">资源uid</param>
        /// <param name="tag">资源上的Tag</param>
        /// <param name="appVerify">验证字符串</param>
        /// <returns>成功为正，权限不足失败为0，服务器拒绝为-1</returns>
        [OperationContract]
        int RemoveTag(long uid, Tag tag, string appVerify);

    }
}
